package com.gduf.lsm.mapper;

import com.gduf.lsm.common.annotation.AutoFill;
import com.gduf.lsm.common.enums.OperationType;
import com.gduf.lsm.entity.JoinActivity;
import com.gduf.lsm.pojo.vo.JoinActivityShowVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 操作joinActivity相关数据接口
*/
@Mapper
public interface JoinActivityMapper {

    /**
     * 新增
     * @param joinActivity
     * @return
     */
    @AutoFill(value = OperationType.INSERT)
    int insert(JoinActivity joinActivity);

    /**
     * 删除
     * @param id
     * @return
     */
    int deleteById(Integer id);

    /**
     * 修改
     * @param joinActivity
     * @return
     */
    @AutoFill(value = OperationType.UPDATE)
    int updateById(JoinActivity joinActivity);

    /**
     * 根据ID查询
     * @param id
     * @return
     */
    @Select("select * from join_activity where id=#{id}")
    JoinActivity selectById(Integer id);

    /**
     * 查询所有
     * @param joinActivity
     * @return
     */
    List<JoinActivity> selectAll(JoinActivity joinActivity);

    /**
     * 分页条件查询
     * @param joinActivity
     * @return
     */
    List<JoinActivityShowVO> selectPageQuery(JoinActivity joinActivity);

    /**
     * 查询用户是否报名此活动
     * 注意为非”已取消“状态
     * @param id
     * @param userId
     * @return
     */
    @Select("select * from join_activity where act_id=#{id} and user_id=#{userId} and status!='已取消'")
    JoinActivity selectByActIdAndUserId(Integer id, Integer userId);

    /**
     * 查询当前报名人数
     * 注意为非”已取消“状态
     * @param actId
     * @return
     */
    Integer selectJoinByActId(Integer actId);
}